const optionCodeItems = [65,66,67,68,69];


/**
 * 添加选项
 * @param {Array} optionList 选项对象数组
 * **/
export function buildOption(optionList){

    
    //1.判断一下是否存在以上选项
    let optionCode = []

    for(let i = 0;i<optionList.length;i++){
            
        optionCode.push(optionList[i].name.charCodeAt(0))
        
    }
    
    console.log('arr',optionCode);

    //判断两个数组的差异,取差异值
    let difference =  getArrDifference(optionCodeItems,optionCode);
    
    console.log('差异',difference);

    if(difference.length!== 0){
        let option = {name:String.fromCharCode(difference[0]),value:''}

        return option;
    }

    return null;
   
}


/**
 * 判断两个数组的差异
 * @param {Array} arr1 
 * @param {Array} arr2 
 * @returns 
 */
function getArrDifference(arr1,arr2){

    return arr1.concat(arr2).filter(function (v, i, arr) {
        return arr.indexOf(v) === arr.lastIndexOf(v);
    });
    
}

/**
 * 利用JSON的方式,深度拷贝对象 
 * @param {*} entity 
 * @returns 
 */
export function deepCopy(entity){

    return JSON.parse(JSON.stringify(entity));
}
/**
 * 
 * @param {*} value 
 * @param {RegExp} rule 
 * @returns 
 */
export function checkValue(value,rule){
    
    return rule.test(value);
}